import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '@/views/login'
import Layout from '@/views/layout'
// 首页组件
import Home from '@/views/home'
// 视频组件
import Video from '@/views/video'
// 我的组件
import User from '@/views/user'
// 问答组件
import Question from '@/views/question'
// 搜索组件
import Search from '@/views/search'
// 搜索结果组件
import Result from '@/views/search/result.vue'
// 文章详情页组件
import Article from '@/views/article'
// 小智同学组件
import Chat from '@/views/user/chat.vue'
Vue.use(VueRouter)
const routes = [
  // 登录模块
  { name: 'login', path: '/login', component: Login },
  // 欢迎页面
  {
    name: 'layout',
    path: '/',
    component: Layout,
    children: [
      // 默认跳转到首页
      { path: '', component: Home, meta: { isKeepAlive: true } },
      // 问答模块
      { path: '/question', component: Question },
      // 视频模块
      { path: '/video', component: Video },
      // 我的 模块
      { path: '/user', component: User }
    ]
  },
  // 搜索模块
  { name: 'search', path: '/search', component: Search },
  // 搜索结果模块
  { name: 'result', path: '/search/result', component: Result },
  // 文章详情页组件
  { name: 'article', path: '/article/:id', component: Article },
  // 编辑个人资料
  { name: 'userProfile', path: '/user/profile', component: () => import('@/views/user/profile.vue') },
  // 小智同学 组件
  { name: 'chat', path: '/user/chat', component: Chat }
]

const router = new VueRouter({
  routes
})
export default router
